package main

import (
	"fmt"
	"database/sql"
	_ "github.com/go-sql-driver/mysql"
)

func main(){
	db, err := sql.Open("mysql","root:root@(127.0.0.1:3306)/yingxiao");
	if err != nil{
		fmt.Println(err)
	}
	defer db.Close()

	rows, _ := db.Query("select id,nickname from wechat_user")
	id := 0;
    name := "";
	for rows.Next(){        //循环显示所有的数据
        rows.Scan(&id,&name)
        fmt.Println(id,"--",name)
    }

	
}
